package com.easylinkin.linkappapi.progress.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.easylinkin.linkappapi.common.model.RequestModel;
//import com.easylinkin.linkappapi.progress.entity.dto.BimIntegrateProgressDTO;
import com.easylinkin.linkappapi.progress.entity.vo.ProgressInfoVo;
import com.easylinkin.linkappapi.progress.entity.vo.ProgressRealDetailVo;
import com.easylinkin.linkappapi.progress.service.ProgressRealDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;
import java.util.List;

/**
 * 进度管理/实际进度
 *
 * @author zhengwen
 * @date 2023/11/20
 */
@Slf4j
@RestController
@RequestMapping("/progressRealDetail")
public class ProgressRealDetailController extends ApiController {
    /**
     * 服务对象
     */
    @Resource
    private ProgressRealDetailService progressRealDetailService;

    /**
     * 分页查询进度计划末级任务
     *
     * @param requestModel 查询分页对象
     * @return 所有数据
     */
    @PostMapping("/getDtoPage")
    public RestMessage getDtoPage(@RequestBody RequestModel<ProgressRealDetailVo> requestModel) {
        Assert.notNull(requestModel.getCustomQueryParams(), "customQueryParams 不能为空");
        Assert.notNull(requestModel.getPage(), "page 不能为空");
        return progressRealDetailService.getDtoPage(requestModel.getPage(), requestModel.getCustomQueryParams());
    }

    /**
     * 实际进度详情
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/realDetail/{id}")
    public RestMessage realDetail(@PathVariable Long id) {
        Assert.notNull(id, "id 不能为空");
        return progressRealDetailService.realDetail(id);
    }

    /**
     * 新增实际进度填报数据
     *
     * @param progressRealDetailVo 实体对象
     * @return 新增结果
     */
    @PostMapping("/addRealDetail")
    public RestMessage addRealDetail(@RequestBody ProgressRealDetailVo progressRealDetailVo) {
        return progressRealDetailService.addRealDetail(progressRealDetailVo);
    }

    /**
     * 删除进度详情数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @DeleteMapping
    public RestMessage delete(@RequestParam("idList") List<Long> idList) {
        return RestBuilders.successBuilder().success(this.progressRealDetailService.deleteByIds(idList)).build();
    }

//    /**
//     * 大屏实际进度构建信息
//     *
//     * @param requestModel 查询分页对象
//     * @return 统一出参
//     */
//    @PostMapping("/screenRealProgressIntegrateList")
//    public RestMessage screenRealProgressIntegrateList(@RequestBody RequestModel<ProgressInfoVo> requestModel) {
//        //Assert.notNull(requestModel.getCustomQueryParams(), "customQueryParams 不能为空");
//        Assert.notNull(requestModel.getPage(), "page 不能为空");
//        IPage<BimIntegrateProgressDTO> record = progressRealDetailService.screenRealProgressIntegrateList(requestModel.getPage(), requestModel.getCustomQueryParams());
//        return RestBuilders.successBuilder(record).build();
//    }

}

